<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Priithon.plt.dumbdbm_patched</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="Priithon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/priithon">Priithon</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="Priithon-module.html">Package&nbsp;Priithon</a> ::
        <a href="Priithon.plt-module.html">Package&nbsp;plt</a> ::
        Module&nbsp;dumbdbm_patched
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="Priithon.plt.dumbdbm_patched-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="Priithon.plt.dumbdbm_patched-module.html">Module Priithon.plt.dumbdbm_patched</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-docstring">""" A dumb and slow but simple dbm clone.</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">For database spam, spam.dir contains the index (a text file),</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring">spam.bak *may* contain a backup of the index (also a text file),</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring">while spam.dat contains the data (a binary file).</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-docstring">XXX TO DO:</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-docstring">- seems to contain a bug when updating...</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-docstring">- reclaim free space (currently, space once occupied by deleted or expanded</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"><tt class="py-docstring">items is never reused)</tt> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-docstring">- support concurrent access (currently, if two processes take turns making</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring">updates, they can mess up the index)</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-docstring">- support efficient access to large databases (currently, the whole index</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-docstring">is read when the database is opened, and some updates rewrite the whole index)</tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-docstring">- support opening for read-only (flag = 'm')</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-name">_os</tt> <tt class="py-op">=</tt> <tt class="py-name">__import__</tt><tt class="py-op">(</tt><tt class="py-string">'os'</tt><tt class="py-op">)</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">__builtin__</tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt class="py-name">_open</tt> <tt class="py-op">=</tt> <tt class="py-name">__builtin__</tt><tt class="py-op">.</tt><tt id="link-0" class="py-name" targets="Function Priithon.Mrc.open()=Priithon.Mrc-module.html#open,Function Priithon.plt.dumb_shelve.open()=Priithon.plt.dumb_shelve-module.html#open,Function Priithon.plt.dumbdbm_patched.open()=Priithon.plt.dumbdbm_patched-module.html#open,Method Priithon.py.buffer.Buffer.open()=Priithon.py.buffer.Buffer-class.html#open"><a title="Priithon.Mrc.open
Priithon.plt.dumb_shelve.open
Priithon.plt.dumbdbm_patched.open
Priithon.py.buffer.Buffer.open" class="py-name" href="#" onclick="return doclink('link-0', 'open', 'link-0');">open</a></tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line"> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable Priithon.plt.dumbdbm_patched._BLOCKSIZE=Priithon.plt.dumbdbm_patched-module.html#_BLOCKSIZE"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-1', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> <tt class="py-op">=</tt> <tt class="py-number">512</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"> </tt>
<a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-name">error</tt> <tt class="py-op">=</tt> <tt class="py-name">IOError</tt>             <tt class="py-comment"># For anydbm</tt> </tt>
<a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"> </tt>
<a name="_Database"></a><div id="_Database-def"><a name="L33"></a><tt class="py-lineno"> 33</tt> <a class="py-toggle" href="#" id="_Database-toggle" onclick="return toggle('_Database');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html">_Database</a><tt class="py-op">:</tt> </tt>
</div><div id="_Database-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_Database-expanded"><a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"> </tt>
<a name="_Database.__init__"></a><div id="_Database.__init__-def"><a name="L35"></a><tt class="py-lineno"> 35</tt> <a class="py-toggle" href="#" id="_Database.__init__-toggle" onclick="return toggle('_Database.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">file</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.__init__-expanded"><a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dirfile</tt> <tt class="py-op">=</tt> <tt class="py-name">file</tt> <tt class="py-op">+</tt> <tt class="py-string">'.dir'</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt> <tt class="py-op">=</tt> <tt class="py-name">file</tt> <tt class="py-op">+</tt> <tt class="py-string">'.dat'</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_bakfile</tt> <tt class="py-op">=</tt> <tt class="py-name">file</tt> <tt class="py-op">+</tt> <tt class="py-string">'.bak'</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line">        <tt class="py-comment"># Mod by Jack: create data file if needed</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">            <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt><tt class="py-op">,</tt> <tt class="py-string">'r'</tt><tt class="py-op">)</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt> <tt class="py-name">IOError</tt><tt class="py-op">:</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">            <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt><tt class="py-op">,</tt> <tt class="py-string">'w'</tt><tt class="py-op">)</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Method Priithon.Mrc.Mrc.close()=Priithon.Mrc.Mrc-class.html#close,Method Priithon.Mrc.Mrc2.close()=Priithon.Mrc.Mrc2-class.html#close,Method Priithon.Scientific_IO_TextFile.TextFile.close()=Priithon.Scientific_IO_TextFile.TextFile-class.html#close,Method Priithon.plt.dumbdbm_patched._Database.close()=Priithon.plt.dumbdbm_patched._Database-class.html#close,Function Priithon.plt.interface.close()=Priithon.plt.interface-module.html#close,Method Priithon.readerSPE.File.close()=Priithon.readerSPE.File-class.html#close"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-2', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-3" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database._update()=Priithon.plt.dumbdbm_patched._Database-class.html#_update"><a title="Priithon.plt.dumbdbm_patched._Database._update" class="py-name" href="#" onclick="return doclink('link-3', '_update', 'link-3');">_update</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">     </tt>
<a name="_Database._update"></a><div id="_Database._update-def"><a name="L47"></a><tt class="py-lineno"> 47</tt> <a class="py-toggle" href="#" id="_Database._update-toggle" onclick="return toggle('_Database._update');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#_update">_update</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database._update-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database._update-expanded"><a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">        <tt class="py-keyword">import</tt> <tt id="link-4" class="py-name" targets="Module Priithon.string=Priithon.string-module.html"><a title="Priithon.string" class="py-name" href="#" onclick="return doclink('link-4', 'string', 'link-4');">string</a></tt>    </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">            <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dirfile</tt><tt class="py-op">)</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt> <tt class="py-name">IOError</tt><tt class="py-op">:</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">            <tt class="py-keyword">pass</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">            <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">                <tt class="py-name">line</tt> <tt class="py-op">=</tt> <tt id="link-5" class="py-name"><a title="Priithon.string" class="py-name" href="#" onclick="return doclink('link-5', 'string', 'link-4');">string</a></tt><tt class="py-op">.</tt><tt class="py-name">rstrip</tt><tt class="py-op">(</tt><tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Method Priithon.Scientific_IO_TextFile.TextFile.readline()=Priithon.Scientific_IO_TextFile.TextFile-class.html#readline,Method Priithon.py.pseudo.PseudoFile.readline()=Priithon.py.pseudo.PseudoFile-class.html#readline,Method Priithon.py.shell.Shell.readline()=Priithon.py.shell.Shell-class.html#readline"><a title="Priithon.Scientific_IO_TextFile.TextFile.readline
Priithon.py.pseudo.PseudoFile.readline
Priithon.py.shell.Shell.readline" class="py-name" href="#" onclick="return doclink('link-6', 'readline', 'link-6');">readline</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">line</tt><tt class="py-op">:</tt> <tt class="py-keyword">break</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">                <tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">eval</tt><tt class="py-op">(</tt><tt class="py-name">line</tt><tt class="py-op">)</tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line">            <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-7" class="py-name"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-7', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line"> </tt>
<a name="_Database._commit"></a><div id="_Database._commit-def"><a name="L62"></a><tt class="py-lineno"> 62</tt> <a class="py-toggle" href="#" id="_Database._commit-toggle" onclick="return toggle('_Database._commit');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#_commit">_commit</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database._commit-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database._commit-expanded"><a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> <tt class="py-name">_os</tt><tt class="py-op">.</tt><tt class="py-name">unlink</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_bakfile</tt><tt class="py-op">)</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt> <tt class="py-name">_os</tt><tt class="py-op">.</tt><tt class="py-name">error</tt><tt class="py-op">:</tt> <tt class="py-keyword">pass</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> <tt class="py-name">_os</tt><tt class="py-op">.</tt><tt class="py-name">rename</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dirfile</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_bakfile</tt><tt class="py-op">)</tt> </tt>
<a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt> <tt class="py-name">_os</tt><tt class="py-op">.</tt><tt class="py-name">error</tt><tt class="py-op">:</tt> <tt class="py-keyword">pass</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line">        <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dirfile</tt><tt class="py-op">,</tt> <tt class="py-string">'w'</tt><tt class="py-op">)</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">            <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name" targets="Method Priithon.Scientific_IO_TextFile.TextFile.write()=Priithon.Scientific_IO_TextFile.TextFile-class.html#write,Method Priithon.py.document.Document.write()=Priithon.py.document.Document-class.html#write,Method Priithon.py.editwindow.EditWindow.write()=Priithon.py.editwindow.EditWindow-class.html#write,Method Priithon.py.pseudo.PseudoFile.write()=Priithon.py.pseudo.PseudoFile-class.html#write,Method Priithon.py.shell.Shell.write()=Priithon.py.shell.Shell-class.html#write"><a title="Priithon.Scientific_IO_TextFile.TextFile.write
Priithon.py.document.Document.write
Priithon.py.editwindow.EditWindow.write
Priithon.py.pseudo.PseudoFile.write
Priithon.py.shell.Shell.write" class="py-name" href="#" onclick="return doclink('link-8', 'write', 'link-8');">write</a></tt><tt class="py-op">(</tt><tt class="py-string">"%s, (%s, %s)\n"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-op">`</tt><tt class="py-name">key</tt><tt class="py-op">`</tt><tt class="py-op">,</tt> <tt class="py-op">`</tt><tt class="py-name">pos</tt><tt class="py-op">`</tt><tt class="py-op">,</tt> <tt class="py-op">`</tt><tt class="py-name">siz</tt><tt class="py-op">`</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-9" class="py-name"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-9', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">     </tt>
<a name="_Database.__getitem__"></a><div id="_Database.__getitem__-def"><a name="L72"></a><tt class="py-lineno"> 72</tt> <a class="py-toggle" href="#" id="_Database.__getitem__-toggle" onclick="return toggle('_Database.__getitem__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#__getitem__">__getitem__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.__getitem__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.__getitem__-expanded"><a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">        <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-comment"># may raise KeyError</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt><tt class="py-op">,</tt> <tt class="py-string">'rb'</tt><tt class="py-op">)</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt class="py-name">seek</tt><tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">)</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">        <tt class="py-name">dat</tt> <tt class="py-op">=</tt> <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name" targets="Method Priithon.py.document.Document.read()=Priithon.py.document.Document-class.html#read"><a title="Priithon.py.document.Document.read" class="py-name" href="#" onclick="return doclink('link-10', 'read', 'link-10');">read</a></tt><tt class="py-op">(</tt><tt class="py-name">siz</tt><tt class="py-op">)</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-11" class="py-name"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-11', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">dat</tt> </tt>
</div><a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">     </tt>
<a name="_Database._addval"></a><div id="_Database._addval-def"><a name="L80"></a><tt class="py-lineno"> 80</tt> <a class="py-toggle" href="#" id="_Database._addval-toggle" onclick="return toggle('_Database._addval');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#_addval">_addval</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">val</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database._addval-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database._addval-expanded"><a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line">        <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt><tt class="py-op">,</tt> <tt class="py-string">'rb+'</tt><tt class="py-op">)</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt class="py-name">seek</tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">,</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">        <tt class="py-name">pos</tt> <tt class="py-op">=</tt> <tt class="py-name">f</tt><tt class="py-op">.</tt><tt class="py-name">tell</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-comment">## Does not work under MW compiler</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##      pos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##      f.seek(pos)</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-name">npos</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">pos</tt> <tt class="py-op">+</tt> <tt id="link-12" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-12', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> <tt class="py-op">-</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">/</tt> <tt id="link-13" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-13', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt id="link-14" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-14', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="Priithon.Scientific_IO_TextFile.TextFile.write
Priithon.py.document.Document.write
Priithon.py.editwindow.EditWindow.write
Priithon.py.pseudo.PseudoFile.write
Priithon.py.shell.Shell.write" class="py-name" href="#" onclick="return doclink('link-15', 'write', 'link-8');">write</a></tt><tt class="py-op">(</tt><tt class="py-string">'\0'</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">npos</tt><tt class="py-op">-</tt><tt class="py-name">pos</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">        <tt class="py-name">pos</tt> <tt class="py-op">=</tt> <tt class="py-name">npos</tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">         </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name"><a title="Priithon.Scientific_IO_TextFile.TextFile.write
Priithon.py.document.Document.write
Priithon.py.editwindow.EditWindow.write
Priithon.py.pseudo.PseudoFile.write
Priithon.py.shell.Shell.write" class="py-name" href="#" onclick="return doclink('link-16', 'write', 'link-8');">write</a></tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-17" class="py-name"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-17', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">     </tt>
<a name="_Database._setval"></a><div id="_Database._setval-def"><a name="L95"></a><tt class="py-lineno"> 95</tt> <a class="py-toggle" href="#" id="_Database._setval-toggle" onclick="return toggle('_Database._setval');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#_setval">_setval</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">pos</tt><tt class="py-op">,</tt> <tt class="py-param">val</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database._setval-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database._setval-expanded"><a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line">        <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt><tt class="py-op">,</tt> <tt class="py-string">'rb+'</tt><tt class="py-op">)</tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt class="py-name">seek</tt><tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">)</tt> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-18" class="py-name"><a title="Priithon.Scientific_IO_TextFile.TextFile.write
Priithon.py.document.Document.write
Priithon.py.editwindow.EditWindow.write
Priithon.py.pseudo.PseudoFile.write
Priithon.py.shell.Shell.write" class="py-name" href="#" onclick="return doclink('link-18', 'write', 'link-8');">write</a></tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-19', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">     </tt>
<a name="_Database._addkey"></a><div id="_Database._addkey-def"><a name="L102"></a><tt class="py-lineno">102</tt> <a class="py-toggle" href="#" id="_Database._addkey-toggle" onclick="return toggle('_Database._addkey');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#_addkey">_addkey</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-param">pos</tt><tt class="py-op">,</tt> <tt class="py-param">siz</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database._addkey-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database._addkey-expanded"><a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">        <tt class="py-name">f</tt> <tt class="py-op">=</tt> <tt class="py-name">_open</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dirfile</tt><tt class="py-op">,</tt> <tt class="py-string">'a'</tt><tt class="py-op">)</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-20" class="py-name"><a title="Priithon.Scientific_IO_TextFile.TextFile.write
Priithon.py.document.Document.write
Priithon.py.editwindow.EditWindow.write
Priithon.py.pseudo.PseudoFile.write
Priithon.py.shell.Shell.write" class="py-name" href="#" onclick="return doclink('link-20', 'write', 'link-8');">write</a></tt><tt class="py-op">(</tt><tt class="py-string">"%s, (%s, %s)\n"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-op">`</tt><tt class="py-name">key</tt><tt class="py-op">`</tt><tt class="py-op">,</tt> <tt class="py-op">`</tt><tt class="py-name">pos</tt><tt class="py-op">`</tt><tt class="py-op">,</tt> <tt class="py-op">`</tt><tt class="py-name">siz</tt><tt class="py-op">`</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">        <tt class="py-name">f</tt><tt class="py-op">.</tt><tt id="link-21" class="py-name"><a title="Priithon.Mrc.Mrc.close
Priithon.Mrc.Mrc2.close
Priithon.Scientific_IO_TextFile.TextFile.close
Priithon.plt.dumbdbm_patched._Database.close
Priithon.plt.interface.close
Priithon.readerSPE.File.close" class="py-name" href="#" onclick="return doclink('link-21', 'close', 'link-2');">close</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">     </tt>
<a name="_Database.__setitem__"></a><div id="_Database.__setitem__-def"><a name="L108"></a><tt class="py-lineno">108</tt> <a class="py-toggle" href="#" id="_Database.__setitem__-toggle" onclick="return toggle('_Database.__setitem__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#__setitem__">__setitem__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">,</tt> <tt class="py-param">val</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.__setitem__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.__setitem__-expanded"><a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">type</tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-name">type</tt><tt class="py-op">(</tt><tt class="py-string">''</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-name">type</tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">TypeError</tt><tt class="py-op">,</tt> <tt class="py-string">"keys and values must be strings"</tt> </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">.</tt><tt id="link-22" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database.has_key()=Priithon.plt.dumbdbm_patched._Database-class.html#has_key"><a title="Priithon.plt.dumbdbm_patched._Database.has_key" class="py-name" href="#" onclick="return doclink('link-22', 'has_key', 'link-22');">has_key</a></tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">            <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-23" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database._addval()=Priithon.plt.dumbdbm_patched._Database-class.html#_addval"><a title="Priithon.plt.dumbdbm_patched._Database._addval" class="py-name" href="#" onclick="return doclink('link-23', '_addval', 'link-23');">_addval</a></tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-24" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database._addkey()=Priithon.plt.dumbdbm_patched._Database-class.html#_addkey"><a title="Priithon.plt.dumbdbm_patched._Database._addkey" class="py-name" href="#" onclick="return doclink('link-24', '_addkey', 'link-24');">_addkey</a></tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">            <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">            <tt class="py-name">oldblocks</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">siz</tt> <tt class="py-op">+</tt> <tt id="link-25" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-25', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> <tt class="py-op">-</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">/</tt> <tt id="link-26" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-26', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">            <tt class="py-name">newblocks</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt id="link-27" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-27', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> <tt class="py-op">-</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">/</tt> <tt id="link-28" class="py-name"><a title="Priithon.plt.dumbdbm_patched._BLOCKSIZE" class="py-name" href="#" onclick="return doclink('link-28', '_BLOCKSIZE', 'link-1');">_BLOCKSIZE</a></tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">newblocks</tt> <tt class="py-op">&lt;=</tt> <tt class="py-name">oldblocks</tt><tt class="py-op">:</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">                <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-29" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database._setval()=Priithon.plt.dumbdbm_patched._Database-class.html#_setval"><a title="Priithon.plt.dumbdbm_patched._Database._setval" class="py-name" href="#" onclick="return doclink('link-29', '_setval', 'link-29');">_setval</a></tt><tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">val</tt><tt class="py-op">)</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">                <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-30" class="py-name"><a title="Priithon.plt.dumbdbm_patched._Database._addval" class="py-name" href="#" onclick="return doclink('link-30', '_addval', 'link-23');">_addval</a></tt><tt class="py-op">(</tt><tt class="py-name">val</tt><tt class="py-op">)</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-31" class="py-name"><a title="Priithon.plt.dumbdbm_patched._Database._addkey" class="py-name" href="#" onclick="return doclink('link-31', '_addkey', 'link-24');">_addkey</a></tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">siz</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line">     </tt>
<a name="_Database.__delitem__"></a><div id="_Database.__delitem__-def"><a name="L126"></a><tt class="py-lineno">126</tt> <a class="py-toggle" href="#" id="_Database.__delitem__-toggle" onclick="return toggle('_Database.__delitem__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#__delitem__">__delitem__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.__delitem__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.__delitem__-expanded"><a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line">        <tt class="py-keyword">del</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-32" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database._commit()=Priithon.plt.dumbdbm_patched._Database-class.html#_commit"><a title="Priithon.plt.dumbdbm_patched._Database._commit" class="py-name" href="#" onclick="return doclink('link-32', '_commit', 'link-32');">_commit</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line">     </tt>
<a name="_Database.keys"></a><div id="_Database.keys-def"><a name="L130"></a><tt class="py-lineno">130</tt> <a class="py-toggle" href="#" id="_Database.keys-toggle" onclick="return toggle('_Database.keys');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#keys">keys</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.keys-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.keys-expanded"><a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">.</tt><tt id="link-33" class="py-name" targets="Method Priithon.plt.dumbdbm_patched._Database.keys()=Priithon.plt.dumbdbm_patched._Database-class.html#keys"><a title="Priithon.plt.dumbdbm_patched._Database.keys" class="py-name" href="#" onclick="return doclink('link-33', 'keys', 'link-33');">keys</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line">     </tt>
<a name="_Database.has_key"></a><div id="_Database.has_key-def"><a name="L133"></a><tt class="py-lineno">133</tt> <a class="py-toggle" href="#" id="_Database.has_key-toggle" onclick="return toggle('_Database.has_key');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#has_key">has_key</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.has_key-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.has_key-expanded"><a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">.</tt><tt id="link-34" class="py-name"><a title="Priithon.plt.dumbdbm_patched._Database.has_key" class="py-name" href="#" onclick="return doclink('link-34', 'has_key', 'link-22');">has_key</a></tt><tt class="py-op">(</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
</div><a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line">     </tt>
<a name="_Database.__len__"></a><div id="_Database.__len__-def"><a name="L136"></a><tt class="py-lineno">136</tt> <a class="py-toggle" href="#" id="_Database.__len__-toggle" onclick="return toggle('_Database.__len__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#__len__">__len__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.__len__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.__len__-expanded"><a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt><tt class="py-op">)</tt> </tt>
</div><a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line">     </tt>
<a name="_Database.close"></a><div id="_Database.close-def"><a name="L139"></a><tt class="py-lineno">139</tt> <a class="py-toggle" href="#" id="_Database.close-toggle" onclick="return toggle('_Database.close');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched._Database-class.html#close">close</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="_Database.close-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="_Database.close-expanded"><a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_index</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_datfile</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dirfile</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_bakfile</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
</div></div><a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line"> </tt>
<a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line"> </tt>
<a name="open"></a><div id="open-def"><a name="L144"></a><tt class="py-lineno">144</tt> <a class="py-toggle" href="#" id="open-toggle" onclick="return toggle('open');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="Priithon.plt.dumbdbm_patched-module.html#open">open</a><tt class="py-op">(</tt><tt class="py-param">file</tt><tt class="py-op">,</tt> <tt class="py-param">flag</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">mode</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="open-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="open-expanded"><a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line">    <tt class="py-comment"># flag, mode arguments are currently ignored</tt> </tt>
<a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-keyword">return</tt> <tt id="link-35" class="py-name" targets="Class Priithon.plt.dumbdbm_patched._Database=Priithon.plt.dumbdbm_patched._Database-class.html"><a title="Priithon.plt.dumbdbm_patched._Database" class="py-name" href="#" onclick="return doclink('link-35', '_Database', 'link-35');">_Database</a></tt><tt class="py-op">(</tt><tt class="py-name">file</tt><tt class="py-op">)</tt> </tt>
</div><a name="L147"></a><tt class="py-lineno">147</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="Priithon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/priithon">Priithon</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Nov 22 14:59:51 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
